package com.hyc.gchatsystem.enums;

import lombok.Getter;

/**
 * @projectName: gchatsystem
 * @package: com.hyc.gchatsystem.enums
 * @className: ReqType
 * @author: 冷环渊 doomwatcher
 * @description: TODO
 * @date: 2022/4/20 13:56
 * @version: 1.0
 */
@Getter
public enum ReqType {
    //枚举内容
    CONN(1, "建立连接"),
    CANCEL(2, "断开连接"),
    ADD_GROUP(10, "创建群组"),
    JOIN_GROUP(20, "加入群组"),
    SEND_MSG(100, "发送消息");


    //编号
    private int num;
    //信息
    private String desc;

    ReqType(int num, String desc) {
        this.num = num;
        this.desc = desc;
    }

    //    增加一个根据数值遍历枚举类型
    public static ReqType getTypeByNum(int num) {
        ReqType[] reqTypes = ReqType.values();
        for (ReqType reqType : reqTypes) {
            if (num == reqType.getNum()) {
                return reqType;
            }
        }
        return ReqType.SEND_MSG;
    }
}
